<template>
  <div class='wrap_footer'>
    <div class='footer_con'>
      <div class='con'>
        <div class='left'>
          <ul>
            <li>
              <i class='phone_icon'></i>
              <span>15013181661</span>
            </li>
            <li>
              <i class='email_icon'></i>
              <span>mkz1661@dingtalk.com</span>
            </li>
            <li>
              <i class='address_icon'></i>
              <span>天津市河西区江西路与合肥道交口西南侧富润中心2-5008</span>
            </li>
          </ul>
        </div>
        <div class='right'>
          <ul>
            <li class='item-list' v-for='(item,index) in appList' :key='index' @click='toggleQrCode(item,index)'>
              <i :class='item.icon' />
              <div class='popup-view' :style="{'display':item.isShow?'flex':'none'}" >
                <div class='list'>
                  <img :src="item.qrCode" alt=''>
                  <span>{{item.hint}}</span>
                </div>
              </div>
            </li>
<!--            <li><img src='../../../public/img/Android.png' alt=''></li>-->
<!--            <li><img src='../../../public/img/webchat.png' alt=''></li>-->
          </ul>
          <img src='../../../public/img/logo2.png' class='logo' alt=''>
        </div>
      </div>
    </div>
    <div class='footer_bottom'>
      <p class='copyright'>©版权所有 天津睐回网络科技有限公司  津ICP备2024011674号</p>
    </div>
  </div>
</template>

<script setup lang='ts'>
import { onMounted, reactive, ref } from 'vue'
import { AdResponseData } from '@/api/home/type'
import { getAppList } from '@/api/home'
import setting from '@/setting'
import { useRoute, useRouter } from 'vue-router'
import { useDeviceInfo } from "@/hooks/deviceInfo"
const {    DeviceType, getDeviceInfo} = useDeviceInfo()
const router = useRouter()
const route = useRoute()
let deviceObj: object = ref({})
onMounted(() => {
  getAppListData()
  deviceObj = getDeviceInfo()
})
// const appList = reactive([
//   {
//     name:'iPhone',
//     icon:'app_iPhone_icon',
//     qrCode:'../../../public/img/img.png',
//     hint:'打开手机扫码',
//     isShow:false,
//   },{
//     name:'Android',
//     icon:'app_Android_icon',
//     qrCode:'../../../public/img/img.png',
//     hint:'打开手机扫码',
//     isShow:false,
//   },{
//     name:'小程序',
//     icon:'app_webChat_icon',
//     qrCode:'../../../public/img/img.png',
//     hint:'打开手机扫码',
//     isShow:false,
//   }
// ])
const currentIndex = ref(-1)
// function toggleQrCode(items,index){
//   currentIndex.value = index
//   // console.log(items,index)
//   appList.map((item) =>{
//     if(items.name ===item.name){
//       item.isShow = !item.isShow
//     }else{
//       item.isShow = false
//     }
//   })
// }
let appList =ref([])
async function getAppListData() {
  let res: AdResponseData = await getAppList()
  console.log('app-res',res)
  let {data} =res
  let datas = data.map(item =>{
    return{
      name:item.versionName,
      clientType:item.clientType,
      icon:item.clientType==='0'?'app_iPhone_icon':item.clientType==='1'?'app_Android_icon':'app_webChat_icon',
      qrCode:item.downloadUrl,
      hint:item.remark,
      isShow:false
    }
  })
  appList.value =reactive(datas)
}
/**
 * 打开二维码或者处理跳转对应下载页
 * @param items
 * @param index
 */
function toggleQrCode(items:object,index){
  if(DeviceType.value=='手机'){
    handleSkip(items.clientType)
  }else if(DeviceType.value=='电脑'){
    currentIndex.value = index
    appList.value.map((item) => {
      if (items.name === item.name) {
        item.isShow = !item.isShow
      } else {
        item.isShow = false
      }
    })
  }else{//平板
    handleSkip(items.clientType)
  }

}

/**
 * 移动端模式，按照点击客户端类型进行跳转
 * @param clientType
 */
function handleSkip(clientType) {
  switch (clientType) {
    case '0'://    苹果
      router.push({ path: '/download' ,params:{link:0}})
      break;
    case '1'://      安卓
      router.push({ path: '/download' ,params:{link:1}})
      break;
    case '3'://微信小程序
      window.location.href =setting.wechatAppletURLScheme
      break;
  }
}
</script>

<style scoped lang='scss'>
.wrap_footer{
  .footer_con {
    width: 100%;
    height: 161px;
    background-color: #000000;
    .con {
      margin: 0 auto;
      display: flex;
      justify-content: space-between;
      font-family: DIN, DIN;
      font-weight: 400;
      font-size: 14px;
      color: rgb(255, 255, 255);
      line-height: 17px;
      text-align: left;
      font-style: normal;
      align-items: center;
      flex-wrap: wrap;
      height: 100%;
      width: 77%;
      .left {
        //margin-top: 46px;
        //margin-left: 154px;
        ul {
          li{
            opacity: 50%;
            padding-bottom: 12px;
            display: flex;
            align-items: center;
            span{
              margin-left: 15px;
            }
            &:last-child{
              padding-bottom: 0;
            }
          }
        }
        i{
          background-size: contain;
          background-repeat: no-repeat;
          background-position: center;
        }
        i.phone_icon{
          background-image: url("../../../public/img/phone.png");
          display: block;
          height: 14px;
          width: 14px;
        }
        i.email_icon{
          background-image: url("../../../public/img/email.png");
          display: block;
          height: 14px;
          width: 14px;
        }
        i.address_icon{
          background-image: url("../../../public/img/address.png");
          display: block;
          height: 17px;
          width: 17px;
        }
      }
      .right {
        //margin-right: 157px;
        display: flex;
        ul{
          display: flex;
          margin-top: 50px;
          li{
            margin-right: 23px;
            &:nth-child(2){
              margin-right: 25px;
            }
            &:last-child{
              margin-right: 40px;
            }
          }
        }
        //000000
        ul{

          li.item-list{
            position: relative;
            i{
              background-repeat: no-repeat;
              background-position: center;
              background-size: contain;
              display: block;
              width: 26px;
              height: 26px;
              //margin-right: 10px;
            }
            i.app_iPhone_icon{
              background-image: url("../../../public/img/apple.png");
            }
            i.app_Android_icon{
              background-image: url("../../../public/img/Android.png");
            }
            i.app_webChat_icon{
              background-image: url("../../../public/img/webchat.png");
            }

            &:hover{
              .popup-view{
                display: flex!important;
              }
            }
            .popup-view{
              position: absolute;
              width: 134px;
              height: 135px;
              background-color: #FFFFFF !important;
              bottom: 45px;
              left: 50%;
              transform: translate(-50%, 0%);
              z-index: 9;
              cursor: unset;
              //display: flex;
              align-items: center;
              justify-content: center;
              //transition: transform 0.25s ease-out, opacity 0.25s ease-out;
              transition: all 0.3s;
              .list{
                display: flex;
                flex-direction: column;
                align-items: center;
                position: relative;
                >img {
                  width: 91px;
                  height: 91px;

                }
                span{
                  font-family: PingFangSC, PingFang SC;
                  font-weight: 400;
                  font-size: 12px;
                  color: #000000;
                  line-height: 17px;
                  letter-spacing: 1px;
                  text-align: left;
                  font-style: normal;
                  padding-top: 4px;
                }
              }
              //三角形
              &::after {
                content: "";
                position: absolute;
                bottom: -9px;
                width: 0;
                height: 0;
                border-left: 8px solid transparent;
                border-right: 8px solid transparent;
                border-top: 10px solid white;
              }
            }
          }
        }
        //999
        img.logo {
          width: 126px;
          height: 69px;
          margin-top: 7px;
        }
      }
    }
  }
  .footer_bottom {
    height: 60px;
    background-color: #212121;
    width: 100%;
    display: flex;
    justify-content: end;
    align-items: center;
    p.copyright {
      font-family: PingFangSC, PingFang SC;
      font-weight: 400;
      font-size: 14px;
      color: rgba(255, 255, 255, 1);
      opacity: 50%;
      line-height: 20px;
      text-align: left;
      font-style: normal;
      margin-right: 157px;
    }
  }
}
</style>
